<template>
	<view>
		<uni-list v-if="!loading&&list.length > 0" class="index-content">
			<uni-list-item class="list-item" :show-arrow="false" v-for="(item, index) in list" :key="index">
				<view class="list-item-wrap">
					<!-- <view v-if="item.title" class="list-title">{{ item.title }}</view> -->
					<view v-if="item.content" class="list-title">{{ item.content }}</view>
					<view class="list-title font1" style="margin-top: 10upx;">类型：{{ getType(item.type) }}</view>
				
					<view class="list-title font1" style="margin-top: 10upx;">金额：￥{{ item.money }}</view>
					<view class="list-title font1" style="margin-top: 10upx;">冻结金额：￥{{ item.frozenAmount }}</view>
					<view class="list-title font1" style="margin-top: 10upx;">冻结状态：{{ getFrozenState(item.frozenState) }}</view>
					<view class="list-title font1" style="margin-top: 10upx;" v-if="item.frozenState==2">解冻金额去向：可提现余额</view>
					<view class="list-title font1" style="margin-top: 10upx;" v-if="item.currentMoney">账户余额：￥{{ item.currentMoney }}</view>
					<view style="display: flex;justify-content: space-between;margin-top: 20rpx;">
						<view>
							<text>创建时间：{{ item.createTime }}</text>
						</view>
					</view>
				</view>
			</uni-list-item>
		</uni-list>
		<!-- 加载更多提示 -->
		<view class="s-col is-col-24" v-if="list.length > 0">
			<load-more :loadingType="loadingType" :contentText="contentText"></load-more>
		</view>
		<!-- 加载更多提示 -->
		<empty v-if="!loading&&list.length === 0" des="暂无数据" show="false"></empty>
	</view>
</template>

<script>
	import uniListItem from '../../components/uni-list-item/uni-list-item.vue';
	import config from '../../../common/config.js'
	export default {
		components: {
			uniListItem
		},
		data() {
			return {
				list: [],
				page: 1,
				size: 10,
				min_id: 1,
				cid: 0,
				type: 1,
				isInvitation: 0,
				sort: 4,
				genderKey: 'gender',
				loadingType: 0,
				scrollTop: false,
				// contentText: {
				// 	contentdown: '上拉显示更多',
				// 	contentrefresh: '正在加载...',
				// 	contentnomore: '没有更多数据了'
				// },
				contentText: {
					contentdown: '没有更多数据了',
					contentrefresh: '正在加载...',
					contentnomore: '没有更多数据了'
				},
				isMall: false,
				loading: true,
			};
		},
		onPageScroll: function(e) {
			this.scrollTop = e.scrollTop > 200;
		},
		onShow() {
			// this.userId = this.$queue.getData('openid');
			this.userId = this.$queue.getData('mallUserId') ? this.$queue.getData('mallUserId') : this.$queue.getData(
				'openid');
			//测试
			// this.userId = '1478751127621156866'
			if (this.isMall) {
				this.getList()
			}

		},
		methods: {
			getPlat(payType) {
				switch (payType) {
					case 1:
						return '微信App'
					case 2:
						return '支付宝App'
					case 3:
						return '微信小程序'
					case 4:
						return '支付宝小程序'
					default:
						break;
				}
			},
			getFrozenState(state){
				switch (state) {
					case 1:
						return '冻结'
					case 2:
						return '解冻'
					
					default:
						break;
				}
			},
			// 0充值1直推奖2推广平级3津贴奖4培育奖5支出消费6提现7代理收益8推荐代理收入9代理激活收入10转账(转入)）11转账(转出))
			getType(type){
				switch (type) {
					case 0:
						return '充值'
					case 1:
						return '直推奖'
					case 2:
						return '推广平级'
					case 3:
						return '津贴奖'
					case 4:
						return '培育奖'
					case 5:
						return '支出消费'
					case 6:
						return '提现'
					case 7:
						return '代理收益'
					case 8:
						return '推荐代理收入'
					case 9:
						return '代理激活收入'
					case 10:
						return '转账(转入)'
					case 11:
						return '转账(转出)'
					
					default:
						break;
				}
			},
			//获取商城数据
			getList() {
				uni.showLoading({})
				uni.request({
					// url:'https://k999az04ootw.ngrok2.xiaomiqiu.cn/p/user/newUserInfo/'+this.userId,
					url: config.mallHost + '/p/user/getFreezeDetails/' + this.userId,
					method: 'GET',
					success: (res) => {
						console.log('冻结明细：', res)
						this.loading = false
						uni.hideLoading()
						this.list = res.data
						// this.list = [
						// 	{title:'购买产品消费支出',content:'4546546',money:'-768'},
						// 	{title:'购买产品消费支出',content:'4546546',money:'-768'},
						// 	{title:'购买产品消费支出',content:'4546546',money:'-768'},
						// ]
					},
					fail: (err) => {
						this.loading = false
						uni.hideLoading()
						console.log('err', err)
					}
				})
			},
			loadList: function(type) {
				console.log('task.....')
				this.loadingType = 1;
				let userId = this.$queue.getData('openid');
				let data = {
					page: this.page,
					limit: this.size,
					userId: userId
				};
				this.$Request.getT('userMoney/selectUserMoneyDetails', data).then(res => {
					if (res.code === 0) {
						if (this.page === 1) {
							this.list = [];
						}
						for (var i = 0; i < res.data.list.length; i++) {
							this.list.push(res.data.list[i]);
						}
						this.min_id = res.min_id;
						if (res.data.list.length === this.size) {
							this.loadingType = 0;
						} else {
							this.loadingType = 3;
						}
					} else {
						this.loadingType = 2;
					}
					uni.hideLoading();
					if (type === 'Refresh') {
						uni.stopPullDownRefresh(); // 停止刷新
					}
				});
			}
		},
		onLoad: function(e) {

			if ('mall' == e.from) {
				console.log('资金明细 mall...')
				this.isMall = true
			}

			//任务
			// this.loadList();
		},
		//商城暂时注释
		// onReachBottom: function() {
		// 	this.page = this.page + 1;
		// 	this.loadList();
		// },
		// onPullDownRefresh: function() {
		// 	this.page = 1;
		// 	this.min_id = 1;
		// 	this.loadList('Refresh');
		// }
	};
</script>

<style lang="less">
	page {
		background: #FFFFFF;
	}

	.index-content {
		background-color: #f3f3f3;

		.list-item {
			background-color: #ffffff;

			.list-item-wrap {
				display: flex;
				flex-direction: column;

				.list-title {
					font-weight: bold;
				}

				.font1 {
					font-weight: 400;
				}
			}
		}
	}
</style>
